package com.mopub.mobileads; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.Location; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.webkit.WebViewDatabase; import android.widget.FrameLayout; import com.PinkiePie; import com.mopub.common.AdFormat; import com.mopub.common.event.BaseEvent; import com.mopub.common.logging.MoPubLog; import com.mopub.common.util.ManifestUtils; import com.mopub.common.util.Visibility; import com.mopub.mobileads.factories.AdViewControllerFactory; import com.mopub.mobileads.factories.CustomEventBannerAdapterFactory; import com.mopub.network.AdResponse; import com.mopub.network.TrackingRequest; import java.util.Map; import java.util.TreeMap; public class MoPubView extends FrameLayout { protected AdViewController Bml; protected CustomEventBannerAdapter Bmm; private int Bmn; private BroadcastReceiver Bmo; BannerAdListener Bmp; private Context mContext; public interface BannerAdListener { void onBannerClicked(MoPubView moPubView); void onBannerCollapsed(MoPubView moPubView); void onBannerExpanded(MoPubView moPubView); void onBannerFailed(MoPubView moPubView, MoPubErrorCode moPubErrorCode); void onBannerLoaded(MoPubView moPubView); } public MoPubView(Context context) { this(context, null); } public MoPubView(Context context, AttributeSet attributeSet) { super(context, attributeSet); ManifestUtils.checkWebViewActivitiesDeclared(context); this.mContext = context; this.Bmn = getVisibility(); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); if (WebViewDatabase.getInstance(context) == null) { MoPubLog.e("Disabling MoPub. Local cache file is inaccessible so MoPub will fail if we try to create a WebView. Details of this Android bug found at:https://code.google.com/p/android/issues/detail?id=10789"); return; } this.Bml = AdViewControllerFactory.create(context, this); this.Bmo = new BroadcastReceiver() { /* class com.mopub.mobileads.MoPubView.AnonymousClass1 */ public final void onReceive(Context context, Intent intent) { if (Visibility.isScreenVisible(MoPubView.this.Bmn) && intent != null) { String action = intent.getAction(); if ("android.intent.action.USER_PRESENT".equals(action)) { MoPubView.this.awz(0); } else if ("android.intent.action.SCREEN_OFF".equals(action)) { MoPubView.this.awz(8); } } } }; IntentFilter intentFilter = new IntentFilter("android.intent.action.SCREEN_OFF"); intentFilter.addAction("android.intent.action.USER_PRESENT"); this.mContext.registerReceiver(this.Bmo, intentFilter); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void awz(int i) { if (this.Bml != null) { if (Visibility.isScreenVisible(i)) { AdViewController adViewController = this.Bml; adViewController.setAutorefreshEnabled(adViewController.BkL); return; } AdViewController adViewController2 = this.Bml; adViewController2.BkL = adViewController2.BkK; adViewController2.setAutorefreshEnabled(false); } } /* access modifiers changed from: protected */ public void F(String str, Map<String, String> map) { if (this.Bml != null) { if (TextUtils.isEmpty(str)) { MoPubLog.d("Couldn't invoke custom event because the server did not specify one."); a(MoPubErrorCode.ADAPTER_NOT_FOUND); return; } if (this.Bmm != null) { this.Bmm.invalidate(); } MoPubLog.d("Loading custom event adapter."); this.Bmm = CustomEventBannerAdapterFactory.create(this, str, map, this.Bml.getBroadcastIdentifier(), this.Bml.getAdReport()); CustomEventBannerAdapter customEventBannerAdapter = this.Bmm; PinkiePie.DianePie(); } } /* access modifiers changed from: protected */ public final void a(MoPubErrorCode moPubErrorCode) { if (this.Bml != null) { this.Bml.a(moPubErrorCode); } } /* access modifiers changed from: protected */ public void c(MoPubErrorCode moPubErrorCode) { if (this.Bmp != null) { this.Bmp.onBannerFailed(this, moPubErrorCode); } } public void destroy() { try { this.mContext.unregisterReceiver(this.Bmo); } catch (Exception e) { MoPubLog.d("Failed to unregister screen state broadcast receiver (never registered)."); } removeAllViews(); if (this.Bml != null) { AdViewController adViewController = this.Bml; if (!adViewController.eZ) { if (adViewController.BkP != null) { adViewController.BkP.cancel(); adViewController.BkP = null; } adViewController.setAutorefreshEnabled(false); adViewController.gPo(); adViewController.BkF = null; adViewController.mContext = null; adViewController.BkG = null; adViewController.eZ = true; } this.Bml = null; } if (this.Bmm != null) { this.Bmm.invalidate(); this.Bmm = null; } } public void forceRefresh() { forceRefresh(null); } public void forceRefresh(AdResponse adResponse) { if (this.Bmm != null) { this.Bmm.invalidate(); this.Bmm = null; } if (this.Bml != null) { this.Bml.gPl(); PinkiePie.DianePie(); } } /* access modifiers changed from: protected */ public final void gPA() { if (this.Bml != null) { AdViewController adViewController = this.Bml; if (adViewController.BgN != null) { TrackingRequest.makeTrackingHttpRequest(adViewController.BgN.getClickTrackingUrl(), adViewController.mContext, BaseEvent.Name.CLICK_REQUEST); } if (this.Bmp != null) { this.Bmp.onBannerClicked(this); } } } /* access modifiers changed from: protected */ public final void gPB() { MoPubLog.d("Tracking impression for native adapter."); if (this.Bml != null) { this.Bml.gPm(); } } /* access modifiers changed from: protected */ public final void gPC() { if (this.Bml != null) { this.Bml.gPn(); } MoPubLog.d("adLoaded"); if (this.Bmp != null) { this.Bmp.onBannerLoaded(this); } } /* access modifiers changed from: package-private */ public final Integer gPz() { if (this.Bml != null) { return Integer.valueOf(this.Bml.BkO); } return null; } public Activity getActivity() { return (Activity) this.mContext; } public AdFormat getAdFormat() { return AdFormat.BANNER; } public int getAdHeight() { if (this.Bml != null) { return this.Bml.getAdHeight(); } return 0; } public String getAdUnitId() { if (this.Bml != null) { return this.Bml.getAdUnitId(); } return null; } public int getAdWidth() { if (this.Bml != null) { return this.Bml.getAdWidth(); } return 0; } public boolean getAutorefreshEnabled() { if (this.Bml != null) { return this.Bml.getAutorefreshEnabled(); } MoPubLog.d("Can't get autorefresh status for destroyed MoPubView. Returning false."); return false; } public BannerAdListener getBannerAdListener() { return this.Bmp; } @Deprecated public String getClickTrackingUrl() { return null; } public String getKeywords() { if (this.Bml != null) { return this.Bml.getKeywords(); } return null; } public Map<String, Object> getLocalExtras() { if (this.Bml == null) { return new TreeMap(); } AdViewController adViewController = this.Bml; return adViewController.BkJ != null ? new TreeMap(adViewController.BkJ) : new TreeMap(); } public Location getLocation() { if (this.Bml != null) { return this.Bml.getLocation(); } return null; } @Deprecated public String getResponseString() { return null; } public boolean getTesting() { if (this.Bml != null) { return this.Bml.getTesting(); } MoPubLog.d("Can't get testing status for destroyed MoPubView. Returning false."); return false; } public void loadAd() { PinkiePie.DianePie(); } public void loadAd(AdResponse adResponse) { if (this.Bml != null) { AdViewController adViewController = this.Bml; PinkiePie.DianePie(); } } /* access modifiers changed from: protected */ public void onWindowVisibilityChanged(int i) { if (Visibility.hasScreenVisibilityChanged(this.Bmn, i)) { this.Bmn = i; awz(this.Bmn); } } public void setAdContentView(View view) { if (this.Bml != null) { AdViewController adViewController = this.Bml; adViewController.mHandler.post( /* JADX ERROR: Method code generation error jadx.core.utils.exceptions.CodegenException: Error generate insn: 0x000d: INVOKE (wrap: android.os.Handler : 0x0006: IGET (r1v0 android.os.Handler) = (r0v1 'adViewController' com.mopub.mobileads.AdViewController) com.mopub.mobileads.AdViewController.mHandler android.os.Handler) (wrap: com.mopub.mobileads.AdViewController$3 : 0x000a: CONSTRUCTOR (r2v0 com.mopub.mobileads.AdViewController$3) = (r0v1 'adViewController' com.mopub.mobileads.AdViewController), (r4v0 'view' android.view.View) call: com.mopub.mobileads.AdViewController.3.<init>(com.mopub.mobileads.AdViewController, android.view.View):void type: CONSTRUCTOR) type: VIRTUAL call: android.os.Handler.post(java.lang.Runnable):boolean in method: com.mopub.mobileads.MoPubView.setAdContentView(android.view.View):void, file: classes12.dex at jadx.core.codegen.InsnGen.makeInsn(InsnGen.java:255) at jadx.core.codegen.InsnGen.makeInsn(InsnGen.java:217) at jadx.core.codegen.RegionGen.makeSimpleBlock(RegionGen.java:110) at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:56) at jadx.core.codegen.RegionGen.makeSimpleRegion(RegionGen.java:93) at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:59) at jadx.core.codegen.RegionGen.makeRegionIndent(RegionGen.java:99) at jadx.core.codegen.RegionGen.makeIf(RegionGen.java:143) at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:63) at jadx.core.codegen.RegionGen.makeSimpleRegion(RegionGen.java:93) at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:59) at jadx.core.codegen.RegionGen.makeSimpleRegion(RegionGen.java:93) at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:59) at jadx.core.codegen.MethodGen.addRegionInsns(MethodGen.java:244) at jadx.core.codegen.MethodGen.addInstructions(MethodGen.java:237) at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:342) at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:295) at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$2(ClassGen.java:264) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395) at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) Caused by: jadx.core.utils.exceptions.CodegenException: Error generate insn: 0x000a: CONSTRUCTOR (r2v0 com.mopub.mobileads.AdViewController$3) = (r0v1 'adViewController' com.mopub.mobileads.AdViewController), (r4v0 'view' android.view.View) call: com.mopub.mobileads.AdViewController.3.<init>(com.mopub.mobileads.AdViewController, android.view.View):void type: CONSTRUCTOR in method: com.mopub.mobileads.MoPubView.setAdContentView(android.view.View):void, file: classes12.dex at jadx.core.codegen.InsnGen.makeInsn(InsnGen.java:255) at jadx.core.codegen.InsnGen.addWrappedArg(InsnGen.java:119) at jadx.core.codegen.InsnGen.addArg(InsnGen.java:103) at jadx.core.codegen.InsnGen.generateMethodArguments(InsnGen.java:806) at jadx.core.codegen.InsnGen.makeInvoke(InsnGen.java:746) at jadx.core.codegen.InsnGen.makeInsnBody(InsnGen.java:367) at jadx.core.codegen.InsnGen.makeInsn(InsnGen.java:249) ... 21 more Caused by: jadx.core.utils.exceptions.JadxRuntimeException: Expected class to be processed at this point, class: com.mopub.mobileads.AdViewController, state: GENERATED_AND_UNLOADED at jadx.core.dex.nodes.ClassNode.ensureProcessed(ClassNode.java:215) at jadx.core.codegen.InsnGen.makeConstructor(InsnGen.java:630) at jadx.core.codegen.InsnGen.makeInsnBody(InsnGen.java:363) at jadx.core.codegen.InsnGen.makeInsn(InsnGen.java:230) ... 27 more */ /* this = this; com.mopub.mobileads.AdViewController r0 = r3.Bml if (r0 == 0) goto L_0x0010 com.mopub.mobileads.AdViewController r0 = r3.Bml android.os.Handler r1 = r0.mHandler com.mopub.mobileads.AdViewController$3 r2 = new com.mopub.mobileads.AdViewController$3 r2.<init>(r4) r1.post(r2) L_0x0010: return */ throw new UnsupportedOperationException("Method not decompiled: com.mopub.mobileads.MoPubView.setAdContentView(android.view.View):void"); } public void setAdUnitId(String str) { if (this.Bml != null) { this.Bml.setAdUnitId(str); } } public void setAutorefreshEnabled(boolean z) { if (this.Bml != null) { AdViewController adViewController = this.Bml; adViewController.BkL = z; adViewController.setAutorefreshEnabled(z); } } public void setBannerAdListener(BannerAdListener bannerAdListener) { this.Bmp = bannerAdListener; } public void setKeywords(String str) { if (this.Bml != null) { this.Bml.setKeywords(str); } } public void setLocalExtras(Map<String, Object> map) { if (this.Bml != null) { this.Bml.BkJ = map != null ? new TreeMap(map) : new TreeMap(); } } public void setLocation(Location location) { if (this.Bml != null) { this.Bml.setLocation(location); } } public void setTesting(boolean z) { if (this.Bml != null) { this.Bml.setTesting(z); } } @Deprecated public void setTimeout(int i) { } }